fn load(&mut self, source_id: &SourceId, kind: Kind) -> CargoResult<()> {
(|| {
- let mut source = source_id.load(self.config);
-
- // Ensure the source has fetched all necessary remote data.
- let p = profile::start(format!("updating: {}", source_id));
- try!(source.update());
- drop(p);
-
+ // Save off the source
+ let source = source_id.load(self.config);
if kind == Kind::Override {
self.overrides.push(source_id.clone());
}
-
- // Save off the source
self.add_source(source_id, source, kind);
- Ok(())
+ // Ensure the source has fetched all necessary remote data.
+ let _p = profile::start(format!("updating: {}", source_id));
+ self.sources.get_mut(source_id).unwrap().update()
}).chain_error(|| human(format!("Unable to update {}", source_id)))
}
{compiling} foo v0.0.1 ([..])
", compiling = COMPILING, updating = UPDATING)));
});
+
+test!(add_a_git_dep {
+ let git = git::new("git", |p| {
+ p.file("Cargo.toml", r#"
+ [project]
+ name = "git"
+ version = "0.5.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ }).unwrap();
+
+ let p = project("foo")
+ .file("Cargo.toml", &format!(r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ a = {{ path = 'a' }}
+ git = {{ git = '{}' }}
+ "#, git.url()))
+ .file("src/lib.rs", "")
+ .file("a/Cargo.toml", r#"
+ [package]
+ name = "a"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("a/src/lib.rs", "");
+
+ assert_that(p.cargo_process("build"), execs().with_status(0));
+
+ File::create(p.root().join("a/Cargo.toml")).unwrap().write_all(format!(r#"
+ [package]
+ name = "a"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ git = {{ git = '{}' }}
+ "#, git.url()).as_bytes()).unwrap();
+
+ assert_that(p.cargo("build"), execs().with_status(0));
+});